<?php
/**
 * Created by PhpStorm.
 * User: 65736
 * Date: 2019/4/3 0003
 * Time: 13:20
 */

namespace app\common\model\user;


use app\common\model\CommonModel;

class UserWxModel extends CommonModel
{
    /**
     * 表名称
     *
     * @var string
     */
    protected $table = "user_wx";

    /**
     * 初始化方法
     * {@inheritDoc}
     * @see CommonModel::initialize()
     */
    protected function initialize()
    {
        parent::initialize();
        // 加入唯一索引
        $this->unique_fields[] = 'union_id';
        $this->unique_fields[] = 'user_id';
    }


    /*
     * 完善数据
     * {@inheritDoc}
     * @see CommonModel::fill_data()
     * pay_type->price,score,price_score
     */
    public function fill_data(array $data)
    {
        $data = parent::fill_data($data);
        $data['avatar'] = $data['avatar'] ? str_replace("http://", "https://", $data['avatar']) : '';
        return $data;
    }
}